Page({

  /**
   * 页面的初始数据
   */
  data: {
    name: "店铺名称",
    payAmount: "0.00",
    orderAmount: "0.00",
    orderNum: 0,
    customer: 0,
    refundAmount: '0.00',
    buttonList: [{
        name: "代客下单",
        id: "handleOrder",
        icon: "/common/images/test.png",
        url: "/pages/order/replaceCustomerOrder/index"
      },
      {
        name: "新增客户",
        id: "handleAdd",
        icon: "/common/images/test.png",
        url: '/pages/user/addCustomer/index?active=1'
      },
      {
        name: "数据报表",
        id: "handleView",
        icon: "/common/images/test.png",
        url: ""
      },
      {
        name: "",
        id: "handleView",
        icon: "",
        url: ""
      }
    ]
  },

  onLoad: function(options) {
    this.getData()
  },

// 获取数据
  getData(){
    let self = this;
    wx.request({
      url: 'https://erp.yilestar.com/weapp/shops/getHomeInfo',
      success(res){
        const data = res.data.data;
        self.setData({
          name: data.shopName,
          payAmount: data.todayPaymentMoney,
          orderAmount: data.todayOrderMoney,
          orderNum: data.todayOrderQty,
          customer: data.todayActiveCustQty,
          refundAmount: data.todayRefundMoney,
        })
      }
    })
  },

  goToOrderList(){
    wx.navigateTo({
      url: '/pages/order/orderList/index',
    })
  },
  switchTab(e){
    const url = e.currentTarget.dataset.url;
    console.log(url)
    wx.switchTab({
      url,
    })
  }

})